<?php
class core_model_cate extends core_model{
	/**
	 * 设置主健名称
	 */
	public function primarykey(){
		return "cid";
	}

	/**
	 * 设置当前表名
	 */
	public function tableName(){
		return core_lib_constant::TABLE_PRE."cate";
	}
	
	function edit($data){
		if(!$this->_pkid) return false;
		if($this->_pkid == $data['pid']) return false;
		if($data['cate_name']) $this->set('cate_name', $data['cate_name']);
		if($data['pid']) $this->set('pid', intval($data['pid']));
		return $this->save();
	}
	
	function create($data){
		if($data['cate_name']) $this->set('cate_name', $data['cate_name']);
		if($data['pid']) $this->set('pid', intval($data['pid']));
		return $this->save();
	}
}